package visiopuce.graph;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

public class ConfigurationPanel implements SelectionListener {

	public Button cbBande = null;
	public Button cbPatient = null;
	public Button cbFamille = null;
	public Button cbAutrePucePatient = null;
	public Button cbChevauchant = null;
	public Button cbChevauchantDup = null;
	public Button cbChevauchantDel = null;
	// public JCheckBox cbFlanquant = null;
	// public JCheckBox cbDGV = null;
	// public JCheckBox cbDGV12del = null;
	// public JCheckBox cbDGV12dup = null;
	// public JCheckBox cbDGV12autre = null;
	public Button cbDGVVariants = null;
	public Button cbIsca = null;
	public Button cbRedon = null;
	public Button cbLyon = null;
	public Button cbOuest = null;
	public Button cbCnpc = null;

	public Button cbGeneNCBI = null;
	public Button cbClone32k = null;
	// public JCheckBox cbClone4x44kagilent = null;
	public Button cbClonetilepath = null;
	public Button cbClone4k = null;
	// public JCheckBox cbSNP6 = null;
	public Button cbProbe = null;
	public Button cbEmpreinte = null;
	public Button cbEuchro = null;
	public Button cbBaseMicroRem = null;
	public Button cbMicroRem = null;
	public Button cbFragile = null;
	private Composite composite;
	private boolean isRegion;
	private Composite col1;
	private Composite col2;
	private SelectionListener selectionListener;

	private Map<String, Boolean> selected;

	public ConfigurationPanel(Composite parent, boolean isRegion) {
		super();
		this.isRegion = isRegion;
		composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new GridLayout(2, true));

		col1 = new Composite(composite, SWT.NONE);
		col1.setLayout(new GridLayout(1, true));

		col2 = new Composite(composite, SWT.NONE);
		col2.setLayout(new GridLayout(1, true));
		selected = new HashMap<String, Boolean>();
		selectionListener = new SelectionListener() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				if (e.getSource() instanceof Button) {
					Button button = (Button) e.getSource();
					selected.put(button.getText(), button.getSelection());
				}
			}

			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub

			}
		};
		createConfigurationItem();
	}

	private void createConfigurationItem() {
		// "CONFIGURATION DES REGIONS VISIBLES";
		cbBande = new Button(col1, SWT.CHECK);
		cbBande.setText("Bandes chomosomiques");
		cbBande.setSelection(true);
		cbBande.setEnabled(false);
		selected.put(cbBande.getText(),true);
		cbBande.addSelectionListener(selectionListener);
		
		
		Label l1 = new Label(col1, SWT.NONE);
		l1.setText("CNV : ");
		l1.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD | SWT.UNDERLINE_SINGLE));

		if (!isRegion) {

			cbPatient = new Button(col1, SWT.CHECK);
			cbPatient.setText("CNV du patient");
			cbPatient.setSelection(true);
			cbPatient.setEnabled(false);
			selected.put(cbPatient.getText(),true);
			cbPatient.addSelectionListener(selectionListener);
			
			cbAutrePucePatient = new Button(col1, SWT.CHECK);
			cbAutrePucePatient.setText("CNV du patient (autre puce)");
			cbAutrePucePatient.setSelection(true);
			selected.put(cbAutrePucePatient.getText(),true);
			cbAutrePucePatient.addSelectionListener(selectionListener);
			
			cbFamille = new Button(col1, SWT.CHECK);
			cbFamille.setText("CNV de la famille");
			cbFamille.setSelection(true);
			selected.put(cbFamille.getText(),true);
			cbFamille.addSelectionListener(selectionListener);
			

		}

		cbChevauchant = new Button(col1, SWT.CHECK);
		cbChevauchant.setText("CNV chevauchants");
		cbChevauchant.setSelection(true);
		selected.put(cbChevauchant.getText(),true);
		cbChevauchant.addSelectionListener(selectionListener);
		
		cbChevauchantDel = new Button(col1, SWT.CHECK);
		cbChevauchantDel.setText("CNV en délétion");
		cbChevauchantDel.setSelection(false);
		selected.put(cbChevauchantDel.getText(),false);
		cbChevauchantDel.addSelectionListener(selectionListener);
		
		cbChevauchantDup = new Button(col1, SWT.CHECK);
		cbChevauchantDup.setText("CNV en duplication");
		cbChevauchantDup.setSelection(false);
		selected.put(cbChevauchantDup.getText(),false);
		cbChevauchantDup.addSelectionListener(selectionListener);
		
		// cbFlanquant = new JCheckBox("Marqueurs flanquants");
		// cbFlanquant.setSelected(true);

		// cbDGV = new JCheckBox("CNV de la base DGV");
		// cbDGV.setSelected(true);
//
//		cbChevauchantDup = new Button(col1, SWT.CHECK);
//		cbChevauchantDup.setText("CNV en duplication");
//		cbChevauchantDup.setSelection(false);
//		selected.put("ChevauchantDup",false);

		
		Label l3 = new Label(col1, SWT.NONE);
		l3.setText("Clones : ");
		l3.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD | SWT.UNDERLINE_SINGLE));
		cbClone32k = new Button(col1, SWT.CHECK);
		cbClone32k.setText("Clones 32K");
		cbClone32k.setSelection(false);
		selected.put(cbClone32k.getText(),false);
		cbClone32k.addSelectionListener(selectionListener);
		
		cbClone4k = new Button(col1, SWT.CHECK);
		cbClone4k.setText("Clones 4K");
		cbClone4k.setSelection(false);
		selected.put(cbClone4k.getText(),false);
		cbClone4k.addSelectionListener(selectionListener);
		
		
		cbClonetilepath = new Button(col1, SWT.CHECK);
		cbClonetilepath.setText("Clones Tilepath");
		cbClonetilepath.setSelection(false);
		selected.put(cbClonetilepath.getText(),false);
		cbClonetilepath.addSelectionListener(selectionListener);
		
		
		// cbClone4x44kagilent = new JCheckBox("Marqueurs 4x44K Agilent");
		Label l4 = new Label(col1, SWT.NONE);
		l4.setText("Marqueurs : ");
		l4.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD | SWT.UNDERLINE_SINGLE));

		// cbSNP6 = new JCheckBox("SNP et CN de la puce SNP 6.0 d'Affymetrix");
		if (!isRegion) {
			cbProbe = new Button(col1, SWT.CHECK);
			cbProbe.setText("Marqueurs de la puce");
			cbProbe.setSelection(true);
			selected.put(cbProbe.getText(),true);
			cbProbe.addSelectionListener(selectionListener);
			
		}
		
		
		Label l2 = new Label(col2, SWT.NONE);
		l2.setText("Ploymorphismes : ");
		l2.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD | SWT.UNDERLINE_SINGLE));

		cbDGVVariants = new Button(col2, SWT.CHECK);
		cbDGVVariants.setText("DGV 2013");
		cbDGVVariants.setSelection(true);
		selected.put(cbDGVVariants.getText(),true);
		cbDGVVariants.addSelectionListener(selectionListener);
		

		cbRedon = new Button(col2, SWT.CHECK);
		cbRedon.setText("CNP Redon");
		cbRedon.setSelection(true);
		selected.put(cbRedon.getText(),true);
		cbRedon.addSelectionListener(selectionListener);
		
		cbLyon = new Button(col2, SWT.CHECK);
		cbLyon.setText("CNP Lyon");
		cbLyon.setSelection(true);
		selected.put(cbLyon.getText(),true);
		cbLyon.addSelectionListener(selectionListener);
		
		cbOuest = new Button(col2, SWT.CHECK);
		cbOuest.setText("CNP Nantes, Rouen, Rennes, Lyon");
		cbOuest.setSelection(true);
		selected.put(cbOuest.getText(),true);
		cbOuest.addSelectionListener(selectionListener);
		
		cbCnpc = new Button(col2, SWT.CHECK);
		cbCnpc.setText("CNP Montpellier");
		cbCnpc.setSelection(false);
		selected.put(cbCnpc.getText(),false);
		cbCnpc.addSelectionListener(selectionListener);
		
		cbIsca = new Button(col2, SWT.CHECK);
		cbIsca.setText("CNV de la base ISCA");
		cbIsca.setSelection(true);
		selected.put(cbIsca.getText(),true);
		cbIsca.addSelectionListener(selectionListener);
		
		cbGeneNCBI = new Button(col2, SWT.CHECK);
		cbGeneNCBI.setText("Séquences génomiques issues de NCBI");
		cbGeneNCBI.setSelection(true);
		selected.put(cbGeneNCBI.getText(),true);
		cbGeneNCBI.addSelectionListener(selectionListener);
		
		Label l5 = new Label(col2, SWT.NONE);
		l5.setText("Autres : ");
		l5.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD | SWT.UNDERLINE_SINGLE));

		cbEmpreinte = new Button(col2, SWT.CHECK);
		cbEmpreinte.setText("Régions soumises à empreinte génomique");
		cbEmpreinte.setSelection(true);
		selected.put(cbEmpreinte.getText(),true);
		cbEmpreinte.addSelectionListener(selectionListener);
		
		cbEuchro = new Button(col2, SWT.CHECK);
		cbEuchro.setText("Variants euchromatiques");
		cbEuchro.setSelection(true);
		selected.put(cbEuchro.getText(),true);
		cbEuchro.addSelectionListener(selectionListener);
		
		cbBaseMicroRem = new Button(col2, SWT.CHECK);
		cbBaseMicroRem.setText("Syndromes liés à des microremaniements issus de Decipher");
		cbBaseMicroRem.setSelection(true);
		selected.put(cbBaseMicroRem.getText(),true);
		cbBaseMicroRem.addSelectionListener(selectionListener);
		
		cbMicroRem = new Button(col2, SWT.CHECK);
		cbMicroRem.setText("Syndromes liés à des microremaniements (OMIM du 13/08/09)");
		cbMicroRem.setSelection(false);
		selected.put(cbMicroRem.getText(),false);
		cbMicroRem.addSelectionListener(selectionListener);
		
		cbFragile = new Button(col2, SWT.CHECK);
		cbFragile.setText("Régions chormosomiques fragiles");
		cbFragile.setSelection(false);
		selected.put(cbFragile.getText(),false);
		cbFragile.addSelectionListener(selectionListener);
		
		col1.pack();
		col2.pack();
		composite.pack();
		
	}

	public void repaint() {
		composite.redraw();
		composite.pack();
	}

	public Map<String, Boolean> getSelected() {
		// TODO Auto-generated method stub
		return selected;
	}

	@Override
	public void widgetSelected(SelectionEvent e) {

	}

	@Override
	public void widgetDefaultSelected(SelectionEvent e) {
		// TODO Auto-generated method stub

	}

}
